package com.ruoyi.web.personequi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.personequi.domain.PersonEqui;
import com.ruoyi.web.personequi.service.IPersonEquiService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 人员设备关联Controller
 * 
 * @author bxm
 * @date 2025-07-30
 */
@RestController
@RequestMapping("/personequi/personequi")
public class PersonEquiController extends BaseController
{
    @Autowired
    private IPersonEquiService personEquiService;

    /**
     * 查询人员设备关联列表
     */
    @PreAuthorize("@ss.hasPermi('personequi:personequi:list')")
    @GetMapping("/list")
    public TableDataInfo list(PersonEqui personEqui)
    {
        startPage();
        List<PersonEqui> list = personEquiService.selectPersonEquiList(personEqui);
        return getDataTable(list);
    }

    /**
     * 导出人员设备关联列表
     */
    @PreAuthorize("@ss.hasPermi('personequi:personequi:export')")
    @Log(title = "人员设备关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PersonEqui personEqui)
    {
        List<PersonEqui> list = personEquiService.selectPersonEquiList(personEqui);
        ExcelUtil<PersonEqui> util = new ExcelUtil<PersonEqui>(PersonEqui.class);
        util.exportExcel(response, list, "人员设备关联数据");
    }

    /**
     * 获取人员设备关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('personequi:personequi:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(personEquiService.selectPersonEquiById(id));
    }

    /**
     * 新增人员设备关联
     */
    @PreAuthorize("@ss.hasPermi('personequi:personequi:add')")
    @Log(title = "人员设备关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PersonEqui personEqui)
    {
        return toAjax(personEquiService.insertPersonEqui(personEqui));
    }

    /**
     * 修改人员设备关联
     */
    @PreAuthorize("@ss.hasPermi('personequi:personequi:edit')")
    @Log(title = "人员设备关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PersonEqui personEqui)
    {
        return toAjax(personEquiService.updatePersonEqui(personEqui));
    }

    /**
     * 删除人员设备关联
     */
    @PreAuthorize("@ss.hasPermi('personequi:personequi:remove')")
    @Log(title = "人员设备关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(personEquiService.deletePersonEquiByIds(ids));
    }
}
